1. Field of the Invention
This invention relates generally to transactional memory computer systems and, more specifically, to a system and method for reducing abort rates in transactional memory systems through compiler optimization of computer code.
2. Description of the Related Art
Shared-memory computer systems allow multiple threads of execution to access and operate on the same memory locations. In such systems, it is often important that a thread execute a series of instructions as a single atomic block. Any other thread that observes memory values resulting from a partial execution of an atomic block, may behave incorrectly.
Transactional memory is a mechanism that allows a thread to execute a series of instructions as a transaction, that is, either completely and atomically or not at all. The instructions comprising a transaction may be executed and then either “committed”, allowing the aggregate effect to be seen by all other threads, or “aborted”, allowing no effect to be seen. Transactional attempts that commit may be said to have “succeeded”, while those that abort may be said to have “failed”. If a transaction aborts, the thread may retry executing the transaction. Transactional memory may be implemented in hardware, software, or a combination thereof.
There are various reasons why a transactional attempt may abort. In some cases, a transactional attempt may fail because it is infeasible to execute the particular instruction sequence transactionally. For example, a given sequence of instructions may be too long to execute transactionally because it may require more transactional resources than are available on the hardware. In another example, it may be infeasible to execute a given instruction sequence transactionally because it contains one or more instructions that cannot be executed transactionally, such as one or more I/O instructions.
In some cases, a transactional attempt may abort or be aborted due to a conflict with another, concurrently executing, thread. For example, if during the execution of a given transaction, another thread modifies a memory location read by the transaction, the transaction may abort. Likewise, if a transaction modifies a shared memory location that is read by another thread before the transaction commits, then the transaction may abort. If the shared memory location were read by the other thread as part of a transaction, it is possible that both transactions would abort. This may be referred to as mutual abort. Repeated transactional aborts may lead to system performance degradation.